package com.process.service.impl;

import com.auth.model.process.ProcessTemplate;
import com.auth.model.process.ProcessType;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.process.mapper.OaProcessTypeMapper;
import com.process.service.OaProcessTemplateService;
import com.process.service.OaProcessTypeService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * <p>
 * 审批类型 服务实现类
 * </p>
 *
 * @author tang
 * @since 2023-07-23
 */
@Service
public class OaProcessTypeServiceImpl extends ServiceImpl<OaProcessTypeMapper, ProcessType> implements OaProcessTypeService {

    private final OaProcessTemplateService processTemplateService;
    public OaProcessTypeServiceImpl(OaProcessTemplateService processTemplateService) {
        this.processTemplateService = processTemplateService;
    }

    /**
     * 查询所有审批分类
     *
     * @author Tangjiachang
     * @date 2023/7/23 18:31
     * @param : 
     * @return List<ProcessType>
     **/
    @Override
    public List<ProcessType> findProcessType() {
        List<ProcessType> types = baseMapper.selectList(null);
        for (ProcessType type : types) {
            List<ProcessTemplate> list = processTemplateService.list(new LambdaQueryWrapper<ProcessTemplate>().eq(ProcessTemplate::getProcessTypeId, type.getId()));
            type.setProcessTemplateList(list);
        }
        return types;
    }
}
